﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.CollectControl.WaterCollectControl.Read
{
    public class PresenterWaterCollectControl
    {
        IWaterCollectControlView view;
        Model.WaterCollectControl waterControl;

        public PresenterWaterCollectControl(IWaterCollectControlView view, Model.WaterCollectControl w)
        {
            this.view = view;
            waterControl = new Model.WaterCollectControl()
            {
                CollectId = w.CollectId,
                CollectPayDate = w.CollectPayDate,
                CollectType = w.CollectType,
                ReadingDate = w.ReadingDate,
                DateGenerated = w.DateGenerated,
                Estructura = w.Estructura,
                IsPaid = w.IsPaid,
                Kardex = w.Kardex,
                KardexId = w.KardexId,
                PaymentAmount = w.PaymentAmount,
                User = w.User,
                UserId = w.UserId,
                WaterReadingId = w.WaterReadingId
            };
        }

        public void LoadDataToView()
        {
            view.Allotment = waterControl.Kardex.Allotment.First().AllotmentName;
            view.Square = waterControl.Kardex.Allotment.First().Square.SquareId;
            view.NamePartner = waterControl.Kardex.Person.Names + " " + waterControl.Kardex.Person.LastNames;
            view.CiPartner = waterControl.Kardex.Person.PersonId;
            view.ReadingDate = waterControl.ReadingDate;
            view.PaymentDate = waterControl.CollectPayDate.Value;
            view.Amount = waterControl.PaymentAmount;
            view.ChargeType = ((Model.WaterExpenseType)waterControl.CollectType).ToString(); 
        }
    }
}
